package com.demo.mybatis;

import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class test {
	/**
	 * @param args
	 */
		public static void main(String[] args) throws IOException{
		String resource="config/configuration.xml";
		Reader reader=Resources.getResourceAsReader(resource);
		SqlSessionFactory sqlMapper=new SqlSessionFactoryBuilder().build(reader);
		SqlSession session=sqlMapper.openSession(); 
		try{
			StudentMapper mapper = session.getMapper(StudentMapper.class);
			Student st=new Student();
			st.setid(24);      
			st.setname("sr");
			st.setage(34);
			mapper.updateStudent(st);
			System.out.println(st);
			//session.commit();
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			session.close();
		}
	}
}
